/* indent size: 2 */

module.exports = app => {
  const DataTypes = app.Sequelize;
  var moment = require("moment");
  const Model = app.model.define(
    "lessee",
    {
      id: {
        type: DataTypes.INTEGER(11),
        allowNull: true,
        primaryKey: true,
        autoIncrement: true
      },
      lesseeId: {
        type: DataTypes.STRING(50),
        allowNull: true
      },
      lesseeName: {
        type: DataTypes.STRING(255),
        allowNull: false,
        unique: true
      },
      createdTime: {
        type: DataTypes.TIME,
        allowNull: true,
        defaultValue: DataTypes.literal("CURRENT_TIMESTAMP"),
        get() {
          return moment(this.getDataValue("createdTime")).format(
            "YYYY-MM-DD HH:mm:ss"
          );
        }
      },
      updatedTime: {
        type: DataTypes.TIME,
        allowNull: true,
        defaultValue: DataTypes.literal("CURRENT_TIMESTAMP"),
        get() {
          return moment(this.getDataValue("updatedTime")).format(
            "YYYY-MM-DD HH:mm:ss"
          );
        }
      }
    },
    {
      tableName: "lessee"
    }
  );

  Model.associate = function () {};

  return Model;
};
